package com.quasar.hpatient.model.custommodel;

import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.quasar.hpatient.utils.UrlUtils;
import com.vise.log.ViseLog;

import java.io.Serializable;

/**
 * author : 许建宏
 * Date: 2017/10/26 0026
 * View:体温
 */

public class TemperatureTableItem implements Serializable,MultiItemEntity {

    public static final int HEAD = 1;
    public static final int BODY = 2;
    public static final int TAIL=3;


    public static final int ONE=4;
    public static final int TWO=5;
    public static final int THREE=6;
    public static final int FOUR=7;
    public static final int FIVE=8;
    public static final int SIX=9;
    public static final int SERVER=10;

    //检测项id
    private int dailyItemId;
    //时间
    public String logTime;//检测时间
    //检测值(上值)
    public String logValue;
    //检测值(下值)
    public String paired;
    //标记
    public String markValues;
    //单位
    public String dailyitemDose;
    //检测项名称
    public String dailyitemName;
    //布局类型
    public int itemType;
    public Integer indexId;

    private float MaxValue;  //最大值
    private float MixValue;   //最小值
    private String stats;

    //参考值
    private String referenceValue;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    private String id;//修改和删除使用的id
    /**
     * 0 代表无参考值
     * 1 代表只有最小值
     * 2 代表只有最大值
     * 3 代表有最大最小值
     */
    private int Status;   //状态

    int Maxstatus = 2;
    int Mixstatus = 1;
    int Nostatus = 0;
    int Allstatus = 3;

    public void Judgereference(String referenceValue) {

        if (referenceValue != null) {
            if (referenceValue.contains("-")) {
                String[] reference = referenceValue.split("-");
                if (reference.length == 2) {

                    if (UrlUtils.StrNum(reference[0]) && UrlUtils.StrNum(reference[1])) {
                        if (Float.parseFloat(reference[0]) == 0) {

                            setMaxValue(Float.parseFloat(reference[1]));
                            setStatus(Maxstatus);

                        } else {
                            setMaxValue(Float.parseFloat(reference[0]));
                            setMixValue(Float.parseFloat(reference[1]));
                            setStatus(Allstatus);
                        }

                    }
                }
            } else if (referenceValue.contains("~")) {
                String[] reference = referenceValue.split("~");
                if (reference.length == 2) {
                    if (UrlUtils.StrNum(reference[0]) && UrlUtils.StrNum(reference[1])) {

                        if(reference[0].equals("0")){
                            setMaxValue(Float.parseFloat("0.001"));
                        }else{
                            setMaxValue(Float.parseFloat(reference[0]));
                        }
                        setMixValue(Float.parseFloat(reference[1]));
                        setStatus(Allstatus);
                    }
                }
            } else if (referenceValue.contains("^")) {
                String[] reference = referenceValue.split("^");
                if (reference.length == 2) {
                    if (UrlUtils.StrNum(reference[0]) && UrlUtils.StrNum(reference[1])) {
                        setMaxValue(Float.parseFloat(reference[0]));
                        setMixValue(Float.parseFloat(reference[1]));
                        setStatus(Allstatus);
                    }
                }
            } else if (referenceValue.contains("<")) {
                String[] reference = referenceValue.split("<");
                if (UrlUtils.StrNum(reference[1])) {
                    setMaxValue(Float.parseFloat(reference[1]));
                    setStatus(Maxstatus);
                }

            } else if (referenceValue.contains("<=")) {
                String[] reference = referenceValue.split("<");
                if (UrlUtils.StrNum(reference[1])) {
                    setMaxValue(Float.parseFloat(reference[1]));
                    setStatus(Maxstatus);
                }

            } else if (referenceValue.contains(">")) {
                String[] reference = referenceValue.split("<");
                if (UrlUtils.StrNum(reference[1])) {
                    setMaxValue(Float.parseFloat(reference[1]));
                    setStatus(Mixstatus);
                }
            } else if (referenceValue.contains(">=")) {
                String[] reference = referenceValue.split("<");
                if (UrlUtils.StrNum(reference[1])) {
                    setMaxValue(Float.parseFloat(reference[1]));
                    setStatus(Mixstatus);
                }
            } else {
                setStatus(Nostatus);
            }
        } else {
            setStatus(Nostatus);
        }
    }

    public Integer getIndexId() {
        return indexId;
    }

    public void setIndexId(Integer indexId) {
        this.indexId = indexId;
    }

    public int getStatus() {
        return Status;
    }

    public void setStatus(int status) {
        Status = status;
    }

    public float getMixValue() {
        return MixValue;
    }

    public void setMixValue(float mixValue) {
        MixValue = mixValue;
    }

    public float getMaxValue() {
        return MaxValue;
    }

    public void setMaxValue(float maxValue) {
        MaxValue = maxValue;
    }

    public String getStats() {
        return stats;
    }

    public void setStats(String stats) {
        this.stats = stats;
    }


    public static int getHEAD() {
        return HEAD;
    }

    public  String getReferenceValue() {
        return referenceValue;
    }
    public void   setReferenceValue(String referenceValue) {
        this.referenceValue = referenceValue;
    }

    public static int getBODY() {
        return BODY;
    }

    public static int getTAIL() {
        return TAIL;
    }

    public int getDailyItemId() {
        return dailyItemId;
    }

    public void setDailyItemId(int dailyItemId) {
        this.dailyItemId = dailyItemId;
    }

    public String getLogTime() {
        return logTime;
    }

    public void setLogTime(String logTime) {
        this.logTime = logTime;
    }

    public String getLogValue() {
        return logValue;
    }

    public void setLogValue(String logValue) {
        this.logValue = logValue;
    }

    public String getDailyitemDose() {
        return dailyitemDose;
    }

    public void setDailyitemDose(String dailyitemDose) {
        this.dailyitemDose = dailyitemDose;
    }

    public String getDailyitemName() {
        return dailyitemName;
    }

    public void setDailyitemName(String dailyitemName) {
        this.dailyitemName = dailyitemName;
    }

    public void setItemType(int itemType) {
        this.itemType = itemType;
    }


    public TemperatureTableItem(int itemType){
        this.itemType=itemType;
    }

    public TemperatureTableItem(){

    }
    public  String  getPaired() {
        return paired;
    }
    public void   setPaired(String paired) {
        this.paired = paired;
    }
    public String getMarkValues() {
        return markValues;
    }
    public void   setMarkValues(String markValues) {
        this.markValues = markValues;
    }

    @Override
    public int getItemType() {
        return itemType;
    }
}
